var UI = {
    button: function(objs) {
        objs = $(objs);
        if(typeof(objs) == "object") {
            var obj;
            var html;
            for(i=0; i<objs.length; i++) {
                html = $('<div class="ui-button-holder"><span></span><div class="ui-button" href="javascript:;"></div></div>');
                obj  = $(objs[i]);
                obj.removeClass("ui-button-placeholder");
                html.addClass(obj.attr("class"))
                    .attr("id", obj.attr("id"));
                html.find(".ui-button")
                    .text(obj.html())
                    .attr("onclick", obj.attr("onclick"));
                obj.after(html).remove();
            }
            
            $('.ui-button-holder').hover(function(){
                $(this).addClass("ui-button-holder-hover");
            }, function(){
                $(this).removeClass("ui-button-holder-hover");
            }).mousedown(function(){
                $(this).addClass("ui-button-holder-active");
            }).mouseup(function(){
                $(this).removeClass("ui-button-holder-active");
            });
        }
    },
    dropdown: function(obj, callback) {
        obj = $(obj);
        
        var the_options_html = $('<div class="ui-dropdown-options"></div>');
        var current_html = $('<div class="ui-dropdown-current"><div class="pb_menu_text ui-dropdown-current-content"></div><div class="ui-arrow-bottom"></div></div>');
        the_options_html.append(obj.html());
        
        obj.html(current_html);
        obj.append(the_options_html);
        
        var current = obj.find(".ui-dropdown-current");
        var the_options = obj.find(".ui-dropdown-options");
        
        obj.find(".ui-dropdown-current-content").html(obj.find(".ui-dropdown-option:first").html());
        if(typeof(callback) == "function"){
            callback(obj.find(".ui-dropdown-option:first").attr('value'));
        }
        current.click(function(){
            the_options.toggle();
            obj.hover(function(){
            }, function(){
                setTimeout(function(){ the_options.hide(); }, 300);
            });
        });
        obj.find(".ui-dropdown-option")
           .click(function(){
               obj.find(".ui-dropdown-current-content").html(this.innerHTML);
               the_options.hide();
               if(typeof(callback) == "function"){
                   callback($(this).attr('value'));
               }
           })
           .hover(function(){
               $(this).addClass('ui-dropdown-option-hover');
           }, function(){
               $(this).removeClass('ui-dropdown-option-hover');
           });
    }
};